/*-
 * Copyright (c) 2006, 2007 FTS Team
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the FTS Team nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      OutputDataCollector.hpp
 *
 * $FTS$
 */
#ifndef _OUTPUT_DATA_COLLECTOR_HPP__
#define _OUTPUT_DATA_COLLECTOR_HPP__ 1

/**
  @file OutputDataCollector.hpp
  @brief Search result collector interface
*/

#include <FTSTypes.h>
#include <DocumentInfo.hpp>
#include <TermStatistic.hpp>

namespace FTSS // FullTextSearchSystem
{

#define C_OUTPUT_NO_ERROR       0x00000000
#define C_OUTPUT_NO_QUERY       0x00000001
#define C_OUTPUT_SYNTAX_EROR    0x00000002
#define C_OUTPUT_INVALID_QUERY  0x00000003
#define C_OUTPUT_UNKNOWN_ERROR  0xFFFFFFFF

/**
  @class OutputDataCollector OutputDataCollector.hpp <OutputDataCollector.hpp>
  @brief Search result collector interface
*/
class OutputDataCollector
{
public:
	/**
	  @brief A virtual destructor
	*/
	virtual ~OutputDataCollector() throw() { ;; }

	/**
	  @brief Store query execution time
	  @param iSec - number of seconds
	  @param iUSec - number of microseconds
	*/
	virtual void ExecTime(const UINT_64 & iSec, const UINT_64 & iUSec) { ;; }

	/**
	  @brief Start search results collection
	  @param iDocumentsCount - Number of documents
	  @param aTerms - List of terms
	  @param iTermsCount - Munber of terms in list
	*/
	virtual void StartOutput(const INT_32 & iDocumentsCount, const TermStatistic * aTerms, const INT_32 & iTermsCount) = 0;

	/**
	  @brief Start new document and store document properties
	  @param pDocumentInfo - Information about document
	  @param dRank - document relevance
	*/
	virtual void StartDocument(const DocumentInfo * pDocumentInfo, const W_FLOAT & dRank) = 0;

	/**
	  @brief End of document
	*/
	virtual void EndDocument() = 0;

	/**
	  @brief Start of snippet
	*/
	virtual void StartSnippet() = 0;

	/**
	  @brief Add snippet data to document
	  @param sSnippet - snippet data
	  @param iLength - snippet data length
	*/
	virtual void AddSnippetData(CCHAR_P sSnippet, const Size_t & iLength) = 0;

	/**
	  @brief Add term to document
	  @param sTerm - Term
	  @param iLength - Term length
	*/
	virtual void AddTerm(CCHAR_P sTerm, const Size_t & iLength) = 0;

	/**
	  @brief End of snippet
	*/
	virtual void EndSnippet() = 0;

	/**
	  @brief End of search result collection
	*/
	virtual void EndOutput() = 0;

	/**
	  @brief Set error code
	  @param iErrorCode - unix error code
	*/
	virtual void SetErrorCode(const INT_32 & iErrorCode) = 0;
};

} // namespace FTSS
#endif // _OUTPUT_DATA_COLLECTOR_HPP__
// End.
